package service.visitor;

import model.Paper;
import model.Student;
import service.PaperSelection;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class CountStudentsVisitor implements PaperSelectionVisitor {
    private int count;
    
    @Override
    public void visit(PaperSelection selection) {
        Set<Student> uniqueStudents = new HashSet<>();
        Map<Paper, Student> selections = selection.getSelections();
        
        for (Student student : selections.values()) {
            uniqueStudents.add(student);
        }
        
        this.count = uniqueStudents.size();
    }
    
    public int getCount() {
        return count;
    }
}